Page({
  data: {
    hasNetworkType: false
  },
  onLoad: function (e) {
    var that = this;
    //监听网络状态变化。
    wx.onNetworkStatusChange(function (res) {
      if(res.isConnected){
        that.setData({
          hasNetworkType: true,
          networkType: res.networkType
        })
      }
    })
  },
  getNetworkType: function () {
    var that = this;
    wx.getNetworkType({
      success: function (res) {
        console.log(res)
        that.setData({
          hasNetworkType: true,
          networkType: res.networkType
        })
          //that.update()
      }
    })
  },
  clear: function () {
    this.setData({
      hasNetworkType: false,
      networkType: ''
    })
  }
})
